package main.java;

public class Triangle {
    private double side1;
    private double side2;
    private double side3;

    public Triangle() {}

    public void setSide1(double side1) {
        this.side1 = side1;
    }

    public void setSide2(double side2) {
        this.side2 = side2;
    }

    public void setSide3(double side3) {
        this.side3 = side3;
    }

    public double getSide1() {
        return side1;
    }

    public double getSide2() {
        return side2;
    }

    public double getSide3() {
        return side3;
    }

    public boolean isValid() {
        return side1 + side2 > side3 && 
               side1 + side3 > side2 && 
               side2 + side3 > side1 &&
               side1 > 0 && side2 > 0 && side3 > 0;
    }

    public double getPerimeter() {
        return side1 + side2 + side3;
    }

    public double getArea() {
        // 使用海伦公式计算面积
        double s = getPerimeter() / 2;
        return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));
    }
}